/*
 * @Author: wanlixin
 * @Date: 2019-10-05 10:41:30
 * @LastEditors: sylvanas
 * @LastEditTime: 2019-11-11 16:06:48
 * @Description: entry file
 */
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import VueRouter from 'vue-router';
import Grimm from '@/index';
import App from './App.vue';
import router from './router';
import FastClick from 'fastclick';
import VueLazyload from 'vue-lazyload';

// 覆盖样式
import '@/common/icon/iconfont.css';
import '@/common/stylus/index.styl';

/* eslint-disable no-unused-vars */
// import vConsole from 'vconsole'

window.Promise = window.Promise || Promise;

FastClick.attach(document.body); //  hack the active pseudo-classes failure caused by -webkit-overflow-scrolling touch

Vue.use(Grimm);
Vue.use(VueRouter);
Vue.use(VueLazyload);

/* eslint-disable no-new */
new Vue({
  router,
  render(createElement) {
    return createElement(App);
  },
}).$mount('#app');

const errorHandler = (error, vm) => {
  console.error('抛出全局异常');
  console.error(vm);
  vm.$createToast({
    type: 'error',
    txt: '代码错误,请检查',
    time: 3000
  }).show()
  console.error(error);
}

Vue.config.errorHandler = errorHandler;
Vue.prototype.$throw = (error) => errorHandler(error, this);
